from django.shortcuts import render

# Create your views here.
from django.http import JsonResponse, HttpResponse
from message_model.models import  MessageTemplet
from users.models import UserProfile

def changeToUse(request):
    u = UserProfile.objects.filter(username=request.user,is_superuser=1)
    if len(u)<1:
        return JsonResponse({"resu": "没有权限！"})
    id = request.POST.get('id')
    messageTemplete = MessageTemplet.objects.filter(id=id).update(status = 2)
    return JsonResponse({"resu":"success"})

def changeToNotUse(request):
    u = UserProfile.objects.filter(username=request.user, is_superuser=1)
    if len(u) < 1:
        return JsonResponse({"resu": "没有权限！"})
    id = request.POST.get('id')
    messageTemplete = MessageTemplet.objects.filter(id=id).update(status = 1)
    return JsonResponse({"resu":"success"})